<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        var endTime = new Date('2017-11-10 18:51:00'),endSeconds = endTime.getTime();
        var d = h = m = s = 0;
        var id = setInterval(seckill,1000);
        function seckill(){
            var nowTime = new Date();
            var remaining = parseInt((endSeconds - nowTime.getTime())/1000);
            if(remaining > 0){
                d = parentInt(remaining/86400);
                h = parentInt((remaining/3600)%24);
                m = parentInt((remaining/60)%60);
                s = parentInt(remaining%60);

                d = d<10?'0'+d:d;
                h = h<10?'0'+h:h;
                m = m<10?'0'+m:m;
                s = s<10?'0'+s:s;
            }else{
                clearInterval(id);
                d = h = m = s = '00';
            }
            document.getElementById('d').innerHTML = d+'天';
            document.getElementById('h').innerHTML = d+'时';
            document.getElementById('m').innerHTML = d+'分';
            document.getElementById('s').innerHTML = d+'秒';
        }
    </script>
</body>
</html>
